<?php

defined('__PET__') or die('Restrict Access');

// load class
foreach ( glob ( 'class/*.php', GLOB_NOSORT ) as $controller ) {
  include_once ($controller);
}  

// load model
foreach ( glob ( 'class/models/*.php', GLOB_NOSORT ) as $controller ) {
  include_once ($controller);
}

function __autoload($className) {
  include_once str_replace ( '_', '/', $className ) . '.php';
}

try {
  // PHP lib config
  if (! function_exists ( 'json_encode' ) || ! function_exists ( 'json_decode' )) {
    throw new DSException ( 503, 'PHP_CONFIG', 'Require the JSON PHP extension.' );
  }
} catch ( DSException $ex ) {
  $this->response = $ex->__toJson ();
  $this->responseStatus = $ex->getCode ();
}  